﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using XiMiBll;
using XiMiModel;

namespace XiaoMiAPI.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OrdersController : ControllerBase
    {
        private readonly OrderBll _orderBll;
        public OrdersController(OrderBll orderBll)
        {
            _orderBll = orderBll;
        }
        [HttpGet]
        public IActionResult ShowOrder()
        {
            var list = _orderBll.ShowOrder();
            return Ok(list);
        }
        [HttpPost]
        public IActionResult AddOrder(OrderModel orderModel)
        {
            return Ok(_orderBll.AddOrder(orderModel));
        }
        [HttpGet]
        public IActionResult Show(int pageindex = 1, int pagesize = 3)
        {
            var totalcount = 0;
            var list = _orderBll.Show(pageindex, pagesize, out totalcount);
            return Ok(new { list, totalcount });
        }
        [HttpGet]
        public IActionResult Fan(int id)
        {
            return Ok(_orderBll.Fan(id));
        }
        [HttpGet]
        public IActionResult Check(int id)
        {
            return Ok(_orderBll.Check(id));
        }
        [HttpGet]
        public IActionResult ShowOrders()
        {
            return Ok(_orderBll.ShowOrders());
        }
    }
}
